package com.lzj.hbase2hdfs;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.mapreduce.TableMapper;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;

import java.io.IOException;

public class PhoneMapper extends TableMapper<Text, IntWritable> {
    @Override
    protected void map(ImmutableBytesWritable key, Result value, Context context) throws IOException, InterruptedException {
        Configuration configuration = HBaseConfiguration.create();

        //获取手机号码   180_20201117171008123
        String rowkey = new String(value.getRow());
        String phoneNum = rowkey.split("_")[0];

        context.write(new Text(phoneNum), new IntWritable(1));
    }
}
  